package com.sznaner.tool.util;

import android.app.Instrumentation;
import android.view.KeyEvent;

import com.sznaner.tool.util.LogUtil;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;



//reboot 重启
//        input keyevent 26 电源键
//        input keyevent 223 息屏
//        input keyevent 224 亮屏
//        input keyevent 82 菜单锁
//        input keyevent 24 音量+键
//        input keyevent 25 音量-键
//        input keyevent 3 Home键
//        input keyevent 4 返回键
//        input keyevent 5 呼叫键
//        input keyevent 6 挂断键
public class DeviceButtonUtil {




    public static ExecutorService mSingleExecutor= Executors.newSingleThreadExecutor();
    public static Instrumentation inst = new Instrumentation();


    public static void home_click(){
        LogUtil.debugLog("Home键");
        mSingleExecutor.execute(key_home_runable);
    }

    public static void back_click(){
        LogUtil.debugLog("返回键");
        mSingleExecutor.execute(key_back_runable);
    }


    public static void volume_up_click(){
        LogUtil.debugLog("按键点击:音量+");
        mSingleExecutor.execute(key_volume_up_runable);
    }

    public static  void  volume_down_click(){
        LogUtil.debugLog("按键点击:音量-");
        mSingleExecutor.execute(key_volume_down_runable);
    }

    public static  void  screenOff(){
        LogUtil.debugLog("熄屏");
        mSingleExecutor.execute(key_screen_off_runable);
    }

    public static  void  weakup(){
        LogUtil.debugLog("唤醒亮屏");
        mSingleExecutor.execute(key_weakup_runable);
    }





    public static Runnable key_volume_up_runable=new Runnable() {
        @Override
        public void run() {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_UP);
        }
    };
    public static Runnable key_volume_down_runable=new Runnable() {
        @Override
        public void run() {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_DOWN);
        }
    };

    public static Runnable key_screen_off_runable=new Runnable() {
        @Override
        public void run() {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_SLEEP);
        }
    };
    public static Runnable key_weakup_runable=new Runnable() {
        @Override
        public void run() {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_WAKEUP);
        }
    };

    public static Runnable key_back_runable = new Runnable() {
        @Override
        public void run() {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
        }
    };

    public static Runnable key_home_runable = new Runnable() {
        @Override
        public void run() {
            inst.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME);
        }
    };


}
